
import { registerClass } from "../../../cfw/tools/class_decorator";
import BaseAd from "../../core/base/BaseAd";
import { SDKState } from "../../SDKDefine";

@registerClass('QQInsertAd')
export default class QQInsertAd extends BaseAd {
    hide(): void {
        throw new Error("Method not implemented.");
    }

    load(): void {
        if (this.ad) {
            this.ad.load();
        }
    }
    show(): void {
        if (this.ad) {
            this.ad.show();
        }
    }

    onClose() {
        console.log(' 插屏广告关闭')
    }

    create() {
        // 创建插屏广告实例，提前初始化
        if (!this.ad) {
            this.ad = this.sdk.createInterstitialAd({
                adUnitId: this.adUnitID
            })
            this.ad.onLoad(this.getFunc(this.onLoad))
            this.ad.onError(this.getFunc(this.onError))
            this.ad.onClose(this.getFunc(this.onClose))
        }
    }
    destroy(): void {
        if (this.ad) {
            this.ad.offLoad(this.getFunc(this.onLoad))
            this.ad.offError(this.getFunc(this.onError))
            this.ad.offClose(this.getFunc(this.onClose))
            this.ad.destroy();
            this.ad = null;
        }
    }



}
